// @author Tjzlo
// @version 2025/4/4 22:42

package com.old.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface RecommendMapper {
    @Insert("INSERT INTO recommend_list(user_id, content_type, content_ids, create_time, update_time) " +
            "VALUES(#{userId}, #{contentType}, #{contentIds}, NOW(), NOW()) " +
            "ON DUPLICATE KEY UPDATE content_ids = VALUES(content_ids), update_time = NOW()")
    void upsertRecommendList(@Param("userId") Integer userId,
                             @Param("contentType") Integer contentType,
                             @Param("contentIds") String contentIds);

    @Select("SELECT content_ids,update_time FROM recommend_list WHERE user_id = #{userId} AND content_type = #{contentType}")
    Map<String, Object> getRecommendContentIdsWithTime(@Param("userId") Integer userId,
                                                       @Param("contentType") Integer contentType);
}
